package com.kpmg.datalake.autopackage.controller;

import com.kpmg.datalake.autopackage.service.PkgAutoService;
import com.kpmg.datalake.autopackage.vo.PackageParamVO;
import com.kpmg.datalake.common.vo.ServerResponse;
import com.kpmg.datalake.operatelog.annotation.OptLog;
import com.kpmg.datalake.operatelog.enums.LogTypeEnum;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Map;

/**
 * @author changpengye
 * @author alex
 */
@RestController
@RequestMapping("/pkgauto")
public class PkgAutoController {
	@Resource
    private PkgAutoService autoService;


    /**
     * queryData
     *
     * @param packageParamVO PackageParamVO
     * @return JSONObject
     */
    @PostMapping(value = "/queryData")
    @OptLog(logType = LogTypeEnum.OPERATION, module = "autoPackage", description = "查询数据")
    public ServerResponse<ArrayList<Map<String, Object>>> queryData(@RequestBody PackageParamVO packageParamVO) {
        return autoService.queryData(packageParamVO);
    }

    /**
     * 更新备注
     *
     * @param packageParamVO packageParamVO
     * @return JSONObject
     */
    @PostMapping(value = "/upRemark")
    @OptLog(logType = LogTypeEnum.OPERATION, module = "autoPackage", description = "批量回填")
    public ServerResponse<String> upRemark(@RequestBody PackageParamVO packageParamVO) {
        return autoService.upRemark(packageParamVO);
    }


    @GetMapping(value = "/pkgDownload")
    @OptLog(logType = LogTypeEnum.OPERATION, module = "autoPackage", description = "自动更新")
    public void pkgDownload(@RequestParam(value = "id") String id,
			HttpServletRequest request, HttpServletResponse response) {
		
		autoService.pkgDownload(id, request, response);
	}
}
